package com.sh.策略模式.strategy.impl.discount;

import com.sh.策略模式.strategy.DiscountStrategy;

public class ShoppingUtil {
    private DiscountStrategy discountStrategy;

    // 指定策略
    public ShoppingUtil(DiscountStrategy discountStrategy) {
        this.discountStrategy = discountStrategy;
    }

    // 默认策略
    public ShoppingUtil() {
        this.discountStrategy = new NormalCustomerDiscount();
    }

    // 计算总价
    public double calculateTotalPrice(double price) {
        return discountStrategy.applyDiscount(price);
    }
}